// 弹框配置文件
export interface FieldConfig {
  key: string;
  label: string;
  type: 'input' | 'textarea' | 'picker' | 'date' | 'datetime' | 'file' | 'multifile';
  icon: string;
  placeholder: string;
  required?: boolean;
  inputType?: string;
  maxlength?: number;
  pattern?: string; // 正则表达式验证
  patternErrorMessage?: string; // 正则验证失败的错误信息
  options?: { value: any; text: string }[];
  rangeKey?: string; // picker模式下用于指定显示的字段名
  tips?: string;
  defaultValue?: any; // 默认值
}

export interface RowConfig {
  key: string;
  fields: FieldConfig[];
}

export interface SectionConfig {
  key: string;
  title: string;
  subtitle: string;
  icon: string;
  rows: RowConfig[];
}

export interface PopupConfig {
  title: string;
  subtitle: string;
  confirmText: string;
  loadingText: string;
  sections: SectionConfig[];
}

// 履历记录弹框配置
export const resumeConfig: PopupConfig = {
  title: "新增履历记录",
  subtitle: "请填写履历记录相关信息",
  confirmText: "确认新增",
  loadingText: "新增中...",
  sections: [
    {
      key: "resume_info",
      title: "履历信息",
      subtitle: "时间等基本信息",
      icon: "compose",
      rows: [
        {
          key: "row1",
          fields: [
            {
              key: "StartDate",
              label: "起始日期",
              type: "date",
              icon: "calendar",
              placeholder: "请选择开始日期",
            },
          ],
        },
        {
          key: "row1_2",
          fields: [
            {
              key: "EndDate",
              label: "结束日期",
              type: "date",
              icon: "calendar",
              placeholder: "请选择结束日期",
            },
          ],
        },
      ],
    },
    {
      key: "original_position",
      title: "原职位信息",
      subtitle: "调整前的部门、岗位及薪资信息",
      icon: "person-filled",
      rows: [
        {
          key: "row1",
          fields: [
            {
              key: "OriginalGroupId",
              label: "原部门",
              type: "picker",
              icon: "home",
              placeholder: "请选择原部门",
              options: [], // 需要动态加载
            },
          ],
        },
        {
          key: "row1_2",
          fields: [
            {
              key: "OriginalPositionId",
              label: "原岗位",
              type: "picker",
              icon: "gear",
              placeholder: "请选择原岗位",
              options: [], // 需要动态加载
            },
          ],
        },
        {
          key: "row2",
          fields: [
            {
              key: "OriginalRank",
              label: "原职级",
              type: "input",
              icon: "person",
              placeholder: "请输入原职级",
            },
            {
              key: "OriginalBaseSalary",
              label: "原基本薪资",
              type: "input",
              icon: "wallet",
              placeholder: "请输入原基本薪资",
              inputType: "number",
            },
          ],
        },
        {
          key: "row3",
          fields: [
            {
              key: "OriginalPositionSalary",
              label: "原岗位薪资",
              type: "input",
              icon: "wallet",
              placeholder: "请输入原岗位薪资",
              inputType: "number",
            },
            {
              key: "OriginalPerformanceSalary",
              label: "原绩效薪资",
              type: "input",
              icon: "wallet",
              placeholder: "请输入原绩效薪资",
              inputType: "number",
            },
          ],
        },
      ],
    },
    {
      key: "new_position",
      title: "调整后信息",
      subtitle: "调整后的部门、岗位及薪资信息",
      icon: "star-filled",
      rows: [
        {
          key: "row1",
          fields: [
            {
              key: "NewGroupId",
              label: "新部门",
              type: "picker",
              icon: "home",
              placeholder: "请选择新部门",
              options: [], // 需要动态加载
            },
          ],
        },
        {
          key: "row1_2",
          fields: [
            {
              key: "NewPositionId",
              label: "新岗位",
              type: "picker",
              icon: "gear",
              placeholder: "请选择新岗位",
              options: [], // 需要动态加载
            },
          ],
        },
        {
          key: "row2",
          fields: [
            {
              key: "NewRank",
              label: "新职级",
              type: "input",
              icon: "person",
              placeholder: "请输入新职级",
            },
            {
              key: "NewBaseSalary",
              label: "新基本薪资",
              type: "input",
              icon: "wallet",
              placeholder: "请输入新基本薪资",
              inputType: "number",
            },
          ],
        },
        {
          key: "row3",
          fields: [
            {
              key: "NewPositionSalary",
              label: "新岗位薪资",
              type: "input",
              icon: "wallet",
              placeholder: "请输入新岗位薪资",
              inputType: "number",
            },
            {
              key: "NewPerformanceSalary",
              label: "新绩效薪资",
              type: "input",
              icon: "wallet",
              placeholder: "请输入新绩效薪资",
              inputType: "number",
            },
          ],
        },
      ],
    },
    {
      key: "resume_details",
      title: "履历详情",
      subtitle: "调整原因及备注信息",
      icon: "chat-filled",
      rows: [
        {
          key: "row1",
          fields: [
            {
              key: "TransferReason",
              label: "调整原因",
              type: "textarea",
              icon: "chat",
              placeholder: "请输入调整原因",
              maxlength: 500,
            },
          ],
        },
        {
          key: "row2",
          fields: [
            {
              key: "Remark",
              label: "备注",
              type: "textarea",
              icon: "compose",
              placeholder: "请输入备注信息",
              maxlength: 500,
            },
          ],
        },
      ],
    },
  ],
};

// 荣誉职称弹框配置
export const honorConfig: PopupConfig = {
  title: "新增荣誉职称",
  subtitle: "请填写荣誉职称相关信息",
  confirmText: "确认新增",
  loadingText: "新增中...",
  sections: [
    {
      key: "honor_info",
      title: "职称信息",
      subtitle: "职称名称、级别等基本信息",
      icon: "star-filled",
      rows: [
        {
          key: "row1",
          fields: [
            {
              key: "QualificationName",
              label: "资质名称",
              type: "input",
              icon: "star",
              placeholder: "请输入资质名称",
              required: true,
            },
          ],
        },
        {
          key: "row1_2",
          fields: [
            {
              key: "ProfessionalTitleTypeId",
              label: "资质类别",
              type: "picker",
              icon: "gear",
              required: true,
              placeholder: "请选择资质类别",
              options: [], // 动态加载
            },
          ],
        },
        {
          key: "row2",
          fields: [
            {
              key: "QualificationLevel",
              label: "资质等级",
              type: "picker",
              icon: "star",
              placeholder: "请选择资质等级",
              options: [
                { value: "高级", text: "高级" },
                { value: "中级", text: "中级" },
                { value: "初级", text: "初级" },
                { value: "国家级", text: "国家级" },
                { value: "省级", text: "省级" },
                { value: "市级", text: "市级" },
                { value: "区县级", text: "区县级" },
                { value: "正高级", text: "正高级" },
                { value: "副高级", text: "副高级" },
                { value: "助理级", text: "助理级" },
                { value: "员级", text: "员级" },
                { value: "一级", text: "一级" },
                { value: "二级", text: "二级" },
                { value: "三级", text: "三级" },
                { value: "四级", text: "四级" },
                { value: "五级", text: "五级" },
                { value: "其他", text: "其他" },
              ],
            },
          ],
        },
        {
          key: "row2_2",
          fields: [
            {
              key: "IssuingAuthority",
              label: "发证单位",
              type: "input",
              icon: "home",
              placeholder: "请输入发证单位",
            }
          ],
        },
        {
          key: "row3",
          fields: [
            {
              key: "CertificateCode",
              label: "证书编码",
              type: "input",
              icon: "paperplane",
              placeholder: "请输入证书编码",
            },
          ],
        },
        {
          key: "row3_2",
          fields: [
            {
              key: "ObtainedDate",
              label: "获得日期",
              type: "date",
              icon: "calendar",
              placeholder: "请选择获得日期",
            }
          ],
        },
        {
          key: "row4",
          fields: [
            {
              key: "ExpiryDate",
              label: "有效期日期",
              type: "date",
              icon: "calendar",
              placeholder: "请选择有效期日期",
            },
          ],
        },
        {
          key: "row5",
          fields: [
            {
              key: "Remark",
              label: "备注",
              type: "input",
              icon: "compose",
              placeholder: "请输入备注信息",
            },
          ],
        },
        {
          key: "row6",
          fields: [
            {
              key: "CertificateDocumentId",
              label: "证书文件",
              type: "file",
              icon: "image",
              placeholder: "请上传证书文件",
              tips: "支持Word、PDF、图片格式",
            },
          ],
        },
      ],
    },
  ],
};

// 学习经历弹框配置
export const educationConfig: PopupConfig = {
  title: "新增学习经历",
  subtitle: "请填写学习经历相关信息",
  confirmText: "确认新增",
  loadingText: "新增中...",
  sections: [
    {
      key: "education_info",
      title: "教育信息",
      subtitle: "学校、专业、学历等基本信息",
      icon: "compose",
      rows: [
        {
          key: "row1",
          fields: [
            {
              key: "School",
              label: "学校",
              type: "input",
              icon: "home",
              placeholder: "请输入学校名称",
              required: true,
            },
            {
              key: "Major",
              label: "专业",
              type: "input",
              icon: "gear",
              placeholder: "请输入专业名称",
            },
          ],
        },
        {
          key: "row2",
          fields: [
            {
              key: "EducationLevel",
              label: "学历",
              type: "picker",
              icon: "star",
              placeholder: "请选择学历层次",
              required: true,
              options: [
                { value: "小学", text: "小学" },
                { value: "初中", text: "初中" },
                { value: "高中", text: "高中" },
                { value: "中专", text: "中专" },
                { value: "大专", text: "大专" },
                { value: "本科", text: "本科" },
                { value: "研究生", text: "研究生" },
                { value: "硕士", text: "硕士" },
                { value: "博士", text: "博士" },
                { value: "博士后", text: "博士后" },
                { value: "博士研究生", text: "博士研究生" },
                { value: "其他", text: "其他" },
              ],
            },
          ],
        },
        {
          key: "row2_2",
          fields: [
            {
              key: "EducationSystem",
              label: "学制",
              type: "picker",
              icon: "gear",
              placeholder: "请选择学制",
              required: true,
              options: [
                { value: "全日制", text: "全日制" },
                { value: "非全日制", text: "非全日制" },
              ],
            },
          ],
        },
        {
          key: "row3",
          fields: [
            {
              key: "EnrollmentDate",
              label: "入学日期",
              type: "date",
              icon: "calendar",
              placeholder: "请选择入学日期",
            },
          ],
        },
        {
          key: "row3_2",
          fields: [
            {
              key: "GraduationDate",
              label: "毕业日期",
              type: "date",
              icon: "calendar",
              placeholder: "请选择毕业日期",
            },
          ],
        },
        {
          key: "row4",
          fields: [
            {
              key: "SelectedEducationFilesIds",
              label: "学历证书",
              type: "multifile",
              icon: "image",
              placeholder: "请上传学历证书",
              tips: "支持Word、PDF、图片格式，可上传多个文件",
            },
          ],
        },
      ],
    },
  ],
};

// 家庭成员弹框配置
export const familyConfig: PopupConfig = {
  title: "新增家庭成员",
  subtitle: "请填写家庭成员相关信息",
  confirmText: "确认新增",
  loadingText: "新增中...",
  sections: [
    {
      key: "family_info",
      title: "家庭成员信息",
      subtitle: "家属姓名、关系等基本信息",
      icon: "person-filled",
      rows: [
        {
          key: "row1",
          fields: [
            {
              key: "MemberName",
              label: "家属姓名",
              type: "input",
              icon: "person",
              placeholder: "请输入家属姓名",
              required: true,
            },
          ],
        },
        {
          key: "row1_2",
          fields: [
            {
              key: "RelationshipType",
              label: "关系类型",
              type: "picker",
              icon: "heart",
              placeholder: "请选择关系类型",
              required: true,
              options: [
                { value: "父亲", text: "父亲" },
                { value: "母亲", text: "母亲" },
                { value: "配偶", text: "配偶" },
                { value: "子女", text: "子女" },
                { value: "其他", text: "其他" },
              ],
            },
          ],
        },
        {
          key: "row2",
          fields: [
            {
              key: "WorkOrSchool",
              label: "工作单位/就读学校",
              type: "input",
              icon: "home",
              placeholder: "请输入工作单位或就读学校名称",
            },
          ],
        },
        {
          key: "row3",
          fields: [
            {
              key: "ContactPhone",
              label: "家属联系电话",
              type: "input",
              icon: "phone",
              placeholder: "请输入家属联系电话",
              inputType: "number",
              maxlength: 11,
              pattern: "^1[3-9]\\d{9}$",
              patternErrorMessage: "请输入正确的手机号码格式",
              required: true,
            },
          ],
        },
      ],
    },
  ],
};

// 工作经历弹框配置
export const workConfig: PopupConfig = {
  title: "新增以往工作经历",
  subtitle: "请填写以往工作经历相关信息",
  confirmText: "确认新增",
  loadingText: "新增中...",
  sections: [
    {
      key: "work_info",
      title: "以往工作经历信息",
      subtitle: "工作单位、岗位、时间等基本信息",
      icon: "home",
      rows: [
        {
          key: "row1",
          fields: [
            {
              key: "Company",
              label: "工作单位",
              type: "input",
              icon: "home",
              placeholder: "请输入工作单位",
              required: true,
            },
            {
              key: "Position",
              label: "岗位",
              type: "input",
              icon: "gear",
              placeholder: "请输入岗位名称",
            },
          ],
        },
        {
          key: "row2",
          fields: [
            {
              key: "StartDate",
              label: "到职日期",
              type: "date",
              icon: "calendar",
              placeholder: "请选择到职日期",
            },
          ],
        },
        {
          key: "row2_2",
          fields: [
            {
              key: "EndDate",
              label: "离职日期",
              type: "date",
              icon: "calendar",
              placeholder: "请选择离职日期",
            },
          ],
        },
        {
          key: "row3",
          fields: [
            {
              key: "Reference",
              label: "证明人",
              type: "input",
              icon: "person",
              placeholder: "请输入证明人姓名",
            },
          ],
        },
      ],
    },
  ],
};
